<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- subApp1😇  -->
        <!-- <h1>{{msg}}</h1> -->
        <!-- or you can use the instruction property offered by vue: -->
        <!-- however,not all vscode previewer support the writing methd😒 (the ctrl+shift+v:preview html support this kind of method.) -->
        <h1 v-bind:title="tit" v-text="msg" v-on:click="showData">
        </h1>
        <!-- subApp2😇😃 -->
        <!-- <button v-on:click="decrease">-</button> -->
        <!-- more simple writing method is using @click to replace  v-on:click -->
        <button @click="decrease">-</button>
        <span>{{number}}</span>
        <button v-on:click="increase">+</button>
        <!-- subApp3😇😃🐬  -->
        <!-- <img v-bind:src=src alt="alice img"> -->
        <!-- the v-bind could be simplied as `:`,or rather,just omit the `v-bind`; -->
        <img :src=src alt="pictures">
        <button @click="changePic(0)">1</button>
        <button @click="changePic(1)">2</button>
        <button @click="changePic(2)">3</button>

    </div>
    <script src="https://unpkg.com/vue@next"></script>
    <script>
        /* just lick the app({ ... }) in weichat miniprogram */
        Vue.createApp({
            // data parts
            data() {
                /* images to show and test */
                alice = "https://gitee.com/xuchaoxin1375/pictures/raw/main/images/alice.jpg"
                aprilFirst_sqare = "https://gitee.com/xuchaoxin1375/pictures/raw/main/images/AprilFirst_square.png"
                aprilFirst_smoke = "https://gitee.com/xuchaoxin1375/pictures/raw/main/images/smoke.jpg"

                return {
                    msg: "hello,view!",
                    tit: "hello vue3(from data())",

                    number: 9,
                    // for img test
                    src: alice,
                    listImgs: [
                        alice,
                        aprilFirst_sqare,
                        aprilFirst_smoke
                    ]
                };
            },
            // method parts:
            methods: {
                showData() {
                    alert("hello vue3")

                }
                ,
                increase() {
                    this.number++;
                },
                decrease() {
                    // make the counter non minus.
                    if (this.number > 0) {

                        this.number--;
                    }
                },
                // part3
                changePic(i) {
                    this.src = this.listImgs[i];

                }
            }
        }).mount("#app");
    </script>
</body>

</html>